package com.cqvie.createDB;


import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.cqvie.util.HibernateConfigurationUtil;

@ContextConfiguration(locations= {"classpath:spring.xml","classpath:spring-hibernate.xml"})
@RunWith(SpringJUnit4ClassRunner.class)
public class CreateDB {

	@Test
	public void test()
	{
		System.out.print("----CreateDB-------");
		Configuration conf=HibernateConfigurationUtil.getConfiguration();
		//Configuration conf= ((LocalSessionFactoryBean)sessionFactory).getConfiguration();
		//将对象模型（类的定义）导出到关系模型（数据库表的定义）
		SchemaExport se=new SchemaExport(conf);
		se.create(true, true);
	}
}
